﻿@model IEnumerable<Blog>

@{
    ViewBag.Title = "Nyheder";
}

<div class="page-header">
    <h1><span class="glyphicon glyphicon-list"></span> @ViewBag.Title</h1>
</div>
<p>
    @Html.ActionLink("Opret ny", "Create")
</p>

<table class="table table-hover">
    <thead>
        <tr>
            <th>
                Dato
            </th>
            <th>
                Titel
            </th>

            <th class="hidden-xs">
                Indhold
            </th>
            <th>
                Skribent
            </th>
        </tr>
    </thead>

    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    <span class="hidden-xs hidden-sm">
                        @item.DateEntry.ToLongDateString()
                    </span>
                    <span class="hidden-md hidden-lg">
                        @item.DateEntry.ToShortDateString()
                    </span>
                </td>
                <td>
                    @Html.ActionLink(@item.Title, "Details", new { id = @item.Id })
                </td>
                <td class="hidden-xs">
                    @if (item.Content.Length > 40)
                    {
                        @item.Content.Substring(0, 40)
                        @Html.Raw("..")
                    }
                    else
                    {
                        @item.Content
                    }
                </td>

                <td>
                    <span class="hidden-xs hidden-sm">
                        @Html.ActionLink(item.Author.DisplayName, "Details", new { id = item.Id }, null)
                    </span>
                    <span class="hidden-md hidden-lg">
                        @Html.ActionLink(item.Author.Initials, "Details", new { id = item.Id }, null)
                    </span>
                </td>
            </tr>
        }
    </tbody>
</table>
